home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / swing / JScrollBar.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  6.6 KB  |  286 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Adjustable;
  4. import java.awt.Component;
  5. import java.awt.Dimension;
  6. import java.awt.event.AdjustmentEvent;
  7. import java.awt.event.AdjustmentListener;
  8. import java.io.IOException;
  9. import java.io.ObjectOutputStream;
  10. import javax.accessibility.Accessible;
  11. import javax.accessibility.AccessibleContext;
  12. import javax.accessibility.AccessibleState;
  13. import javax.swing.event.ChangeListener;
  14. import javax.swing.plaf.ScrollBarUI;
  15.  
  16. public class JScrollBar extends JComponent implements Adjustable, Accessible {
  17.    private static final String uiClassID = "ScrollBarUI";
  18.    private ChangeListener fwdAdjustmentEvents;
  19.    protected BoundedRangeModel model;
  20.    protected int orientation;
  21.    protected int unitIncrement;
  22.    protected int blockIncrement;
  23.  
  24.    private void checkOrientation(int var1) {
  25.       switch (var1) {
  26.          case 0:
  27.          case 1:
  28.             return;
  29.          default:
  30.             throw new IllegalArgumentException("orientation must be one of: VERTICAL, HORIZONTAL");
  31.       }
  32.    }
  33.  
  34.    public JScrollBar(int var1, int var2, int var3, int var4, int var5) {
  35.       this.fwdAdjustmentEvents = new ModelListener(this, (1)null);
  36.       this.checkOrientation(var1);
  37.       this.unitIncrement = 1;
  38.       this.blockIncrement = var3 == 0 ? 1 : var3;
  39.       this.orientation = var1;
  40.       this.model = new DefaultBoundedRangeModel(var2, var3, var4, var5);
  41.       this.model.addChangeListener(this.fwdAdjustmentEvents);
  42.       this.setRequestFocusEnabled(false);
  43.       this.updateUI();
  44.    }
  45.  
  46.    public JScrollBar(int var1) {
  47.       this(var1, 0, 10, 0, 100);
  48.    }
  49.  
  50.    public JScrollBar() {
  51.       this(1);
  52.    }
  53.  
  54.    public void setUI(ScrollBarUI var1) {
  55.       super.setUI(var1);
  56.    }
  57.  
  58.    public ScrollBarUI getUI() {
  59.       return (ScrollBarUI)this.ui;
  60.    }
  61.  
  62.    public void updateUI() {
  63.       this.setUI((ScrollBarUI)UIManager.getUI(this));
  64.    }
  65.  
  66.    public String getUIClassID() {
  67.       return "ScrollBarUI";
  68.    }
  69.  
  70.    public int getOrientation() {
  71.       return this.orientation;
  72.    }
  73.  
  74.    public void setOrientation(int var1) {
  75.       this.checkOrientation(var1);
  76.       int var2 = this.orientation;
  77.       this.orientation = var1;
  78.       this.firePropertyChange("orientation", var2, var1);
  79.       if (var2 != var1 && this.accessibleContext != null) {
  80.          this.accessibleContext.firePropertyChange("AccessibleState", var2 == 1 ? AccessibleState.VERTICAL : AccessibleState.HORIZONTAL, var1 == 1 ? AccessibleState.VERTICAL : AccessibleState.HORIZONTAL);
  81.       }
  82.  
  83.       if (var1 != var2) {
  84.          this.revalidate();
  85.       }
  86.  
  87.    }
  88.  
  89.    public BoundedRangeModel getModel() {
  90.       return this.model;
  91.    }
  92.  
  93.    public void setModel(BoundedRangeModel var1) {
  94.       Integer var2 = null;
  95.       BoundedRangeModel var3 = this.model;
  96.       if (this.model != null) {
  97.          this.model.removeChangeListener(this.fwdAdjustmentEvents);
  98.          var2 = new Integer(this.model.getValue());
  99.       }
  100.  
  101.       this.model = var1;
  102.       if (this.model != null) {
  103.          this.model.addChangeListener(this.fwdAdjustmentEvents);
  104.       }
  105.  
  106.       this.firePropertyChange("model", var3, this.model);
  107.       if (this.accessibleContext != null) {
  108.          this.accessibleContext.firePropertyChange("AccessibleValue", var2, new Integer(this.model.getValue()));
  109.       }
  110.  
  111.    }
  112.  
  113.    public int getUnitIncrement(int var1) {
  114.       return this.unitIncrement;
  115.    }
  116.  
  117.    public void setUnitIncrement(int var1) {
  118.       int var2 = this.unitIncrement;
  119.       this.unitIncrement = var1;
  120.       this.firePropertyChange("unitIncrement", var2, var1);
  121.    }
  122.  
  123.    public int getBlockIncrement(int var1) {
  124.       return this.blockIncrement;
  125.    }
  126.  
  127.    public void setBlockIncrement(int var1) {
  128.       int var2 = this.blockIncrement;
  129.       this.blockIncrement = var1;
  130.       this.firePropertyChange("blockIncrement", var2, var1);
  131.    }
  132.  
  133.    public int getUnitIncrement() {
  134.       return this.unitIncrement;
  135.    }
  136.  
  137.    public int getBlockIncrement() {
  138.       return this.blockIncrement;
  139.    }
  140.  
  141.    public int getValue() {
  142.       return this.getModel().getValue();
  143.    }
  144.  
  145.    public void setValue(int var1) {
  146.       BoundedRangeModel var2 = this.getModel();
  147.       int var3 = var2.getValue();
  148.       var2.setValue(var1);
  149.       if (this.accessibleContext != null) {
  150.          this.accessibleContext.firePropertyChange("AccessibleValue", new Integer(var3), new Integer(var2.getValue()));
  151.       }
  152.  
  153.    }
  154.  
  155.    public int getVisibleAmount() {
  156.       return this.getModel().getExtent();
  157.    }
  158.  
  159.    public void setVisibleAmount(int var1) {
  160.       this.getModel().setExtent(var1);
  161.    }
  162.  
  163.    public int getMinimum() {
  164.       return this.getModel().getMinimum();
  165.    }
  166.  
  167.    public void setMinimum(int var1) {
  168.       this.getModel().setMinimum(var1);
  169.    }
  170.  
  171.    public int getMaximum() {
  172.       return this.getModel().getMaximum();
  173.    }
  174.  
  175.    public void setMaximum(int var1) {
  176.       this.getModel().setMaximum(var1);
  177.    }
  178.  
  179.    public boolean getValueIsAdjusting() {
  180.       return this.getModel().getValueIsAdjusting();
  181.    }
  182.  
  183.    public void setValueIsAdjusting(boolean var1) {
  184.       BoundedRangeModel var2 = this.getModel();
  185.       boolean var3 = var2.getValueIsAdjusting();
  186.       var2.setValueIsAdjusting(var1);
  187.       if (var3 != var1 && this.accessibleContext != null) {
  188.          this.accessibleContext.firePropertyChange("AccessibleState", var3 ? AccessibleState.BUSY : null, var1 ? AccessibleState.BUSY : null);
  189.       }
  190.  
  191.    }
  192.  
  193.    public void setValues(int var1, int var2, int var3, int var4) {
  194.       BoundedRangeModel var5 = this.getModel();
  195.       int var6 = var5.getValue();
  196.       var5.setRangeProperties(var1, var2, var3, var4, var5.getValueIsAdjusting());
  197.       if (this.accessibleContext != null) {
  198.          this.accessibleContext.firePropertyChange("AccessibleValue", new Integer(var6), new Integer(var5.getValue()));
  199.       }
  200.  
  201.    }
  202.  
  203.    public void addAdjustmentListener(AdjustmentListener var1) {
  204.       this.listenerList.add(AdjustmentListener.class, var1);
  205.    }
  206.  
  207.    public void removeAdjustmentListener(AdjustmentListener var1) {
  208.       this.listenerList.remove(AdjustmentListener.class, var1);
  209.    }
  210.  
  211.    public AdjustmentListener[] getAdjustmentListeners() {
  212.       return (AdjustmentListener[])this.listenerList.getListeners(AdjustmentListener.class);
  213.    }
  214.  
  215.    protected void fireAdjustmentValueChanged(int var1, int var2, int var3) {
  216.       this.fireAdjustmentValueChanged(var1, var2, var3, this.getValueIsAdjusting());
  217.    }
  218.  
  219.    private void fireAdjustmentValueChanged(int var1, int var2, int var3, boolean var4) {
  220.       Object[] var5 = this.listenerList.getListenerList();
  221.       AdjustmentEvent var6 = null;
  222.  
  223.       for(int var7 = var5.length - 2; var7 >= 0; var7 -= 2) {
  224.          if (var5[var7] == AdjustmentListener.class) {
  225.             if (var6 == null) {
  226.                var6 = new AdjustmentEvent(this, var1, var2, var3, var4);
  227.             }
  228.  
  229.             ((AdjustmentListener)var5[var7 + 1]).adjustmentValueChanged(var6);
  230.          }
  231.       }
  232.  
  233.    }
  234.  
  235.    public Dimension getMinimumSize() {
  236.       Dimension var1 = this.getPreferredSize();
  237.       return this.orientation == 1 ? new Dimension(var1.width, 5) : new Dimension(5, var1.height);
  238.    }
  239.  
  240.    public Dimension getMaximumSize() {
  241.       Dimension var1 = this.getPreferredSize();
  242.       return this.getOrientation() == 1 ? new Dimension(var1.width, 32767) : new Dimension(32767, var1.height);
  243.    }
  244.  
  245.    public void setEnabled(boolean var1) {
  246.       super.setEnabled(var1);
  247.       Component[] var2 = this.getComponents();
  248.  
  249.       for(int var3 = 0; var3 < var2.length; ++var3) {
  250.          var2[var3].setEnabled(var1);
  251.       }
  252.  
  253.    }
  254.  
  255.    private void writeObject(ObjectOutputStream var1) throws IOException {
  256.       var1.defaultWriteObject();
  257.       if (this.getUIClassID().equals("ScrollBarUI")) {
  258.          byte var2 = JComponent.getWriteObjCounter(this);
  259.          --var2;
  260.          JComponent.setWriteObjCounter(this, var2);
  261.          if (var2 == 0 && this.ui != null) {
  262.             this.ui.installUI(this);
  263.          }
  264.       }
  265.  
  266.    }
  267.  
  268.    protected String paramString() {
  269.       String var1 = this.orientation == 0 ? "HORIZONTAL" : "VERTICAL";
  270.       return super.paramString() + ",blockIncrement=" + this.blockIncrement + ",orientation=" + var1 + ",unitIncrement=" + this.unitIncrement;
  271.    }
  272.  
  273.    public AccessibleContext getAccessibleContext() {
  274.       if (this.accessibleContext == null) {
  275.          this.accessibleContext = new AccessibleJScrollBar(this);
  276.       }
  277.  
  278.       return this.accessibleContext;
  279.    }
  280.  
  281.    // $FF: synthetic method
  282.    static void access$100(JScrollBar var0, int var1, int var2, int var3, boolean var4) {
  283.       var0.fireAdjustmentValueChanged(var1, var2, var3, var4);
  284.    }
  285. }
  286.